<!DOCTYPE html>
<html>
	<head>
		<title>用户管理后台</title>
		<meta charset="UTF-8" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="/helloworld/resources/admin/css/bootstrap.min.css" />
		<link rel="stylesheet" href="/helloworld/resources/admin/css/bootstrap-responsive.min.css" />
		<link rel="stylesheet" href="/helloworld/resources/admin/css/uniform.css" />
		<link rel="stylesheet" href="/helloworld/resources/admin/css/select2.css" />		
		<link rel="stylesheet" href="/helloworld/resources/admin/css/unicorn.main.css" />
		<link rel="stylesheet" href="/helloworld/resources/admin/css/unicorn.grey.css" class="skin-color" />
		<link rel="stylesheet" href="/helloworld/resources/admin/css/style.css" />
		<link rel="stylesheet" href="/helloworld/resources/kindeditor/themes/default/default.css" />
	</head>
	<body>
		<div id="header">
			<h1>用户添加</h1>		
		</div>
		<div id="user-nav" class="navbar navbar-inverse">
            <ul class="nav">
                <li class="btn btn-inverse"></li>
            </ul>
        </div>
		<div id="sidebar">
			<ul>
				<li class="submenu active open" >
					<a href=""><i class="icon icon-leaf"></i> <span>用户管理</span></a>
					<ul>
						<li><a href="/helloworld/user_add.html" target="_self">用户添加</a></li>
						<li><a href="/helloworld/user_list.html" target="_self">用户列表</a></li>
					</ul>
				</li>
			</ul>
		</div>
		<div id="style-switcher">
			<i class="icon-arrow-left icon-white"></i>
			<span>风格:</span>
			<a href="#grey" style="background-color: #555555;border-color: #aaaaaa;"></a>
			<a href="#blue" style="background-color: #2D2F57;"></a>
			<a href="#red" style="background-color: #673232;"></a>
		</div>
		<div id="content">
			<div id="content-header">
				<h1>用户添加</h1>
			</div>
			<div id="breadcrumb">
				<a href="/helloworld/index.html" title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a>
				<a href="#" class="current">用户添加</a>
			</div>
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<div class="widget-box">
							<div class="widget-title">
								<span class="icon">
									<i class="icon-align-justify"></i>									
								</span>
								<h5>添加</h5>
							</div>
							<div class="widget-content nopadding">
								<form class="form-horizontal" method="post" id="myForm" action="/helloworld/user_add.json" >
                                    <div class="control-group">
                                        <label class="control-label">用户名：</label>
                                        <div class="controls">
	                                        <input type="text" name="name" style="width:240px;" required="true" />
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">年龄：</label>
                                        <div class="controls">
	                                         <input type="text" name="age" style="width:240px;" required="true" number="true"/>
                                        </div>
                                    </div>
                                 	<div class="control-group">
                                        <label class="control-label">性别：</label>
                                        <div class="controls">
                                          	<label class="radio-inline">  
	                                          	<input type="radio" name="sex" value="1" checked>男
                                          	</label>  
                                          	<label class="radio-inline">  
	                                          	<input type="radio" name="sex" value="0" >女
                                          	</label>  
                                        </div>
                                    </div>
                                    <div class="form-actions">
                                        <input type="submit" value="保存" id="submitBtn" class="btn btn-success" />
                                        <input type="button" value="取消" class="btn btn-danger" onclick="history.go(-1);"/>
                                    </div>
                                </form>
							</div>
						</div>
					</div>
				</div>
				<div class="row-fluid">
					<div id="footer" class="span12">
						版权所有 2015 hcsoft Corporation. 保留一切权利
					</div>
				</div>
			</div>
		</div>

		<script src="/helloworld/resources/admin/js/jquery.min.js"></script>
		<script src="/helloworld/resources/admin/js/jquery.ui.custom.js"></script>
		<script src="/helloworld/resources/admin/js/bootstrap.min.js"></script>
		<script src="/helloworld/resources/admin/js/jquery.uniform.js"></script>
		<script src="/helloworld/resources/admin/js/select2.min.js"></script>
		<script src="/helloworld/resources/admin/js/jquery.dataTables.min.js"></script>
		<script src="/helloworld/resources/admin/js/unicorn.js"></script>
		<script src="/helloworld/resources/admin/js/unicorn.tables.js"></script>
		<script src="/helloworld/resources/kindeditor/kindeditor.js"></script>
		<script src="/helloworld/resources/kindeditor/lang/zh_CN.js"></script>
		<script type="text/javascript" src="/helloworld/resources/js/jquery.form.js"></script>
		<script type="text/javascript" src="/helloworld/resources/js/jquery.validate.js"></script>
		<script type="text/javascript" src="/helloworld/resources/js/localization/messages_zh.js"></script>
		<script type="text/javascript">
		$(function(){
			$('input[name="username"]').focus();
			
			$("#myForm").validate({
				errorPlacement:function(error,element) {
					var s=element.parent().find("span[htmlFor='" + element.attr("id") + "']");
			      	if(s!=null){
			        	s.remove();
			      	}
			     	error.appendTo(element.parent());
				},
				errorClass: "error",
				submitHandler:function(form){
					formSubmit($("#myForm"));
				}
			});
			
			function formSubmit(form){
			    form.ajaxSubmit({
			        dataType: "json",              
			        success: function(data){
			        	if(data.success="true"){
			        		location.href="/helloworld/user_list.html";
			        	}else{
			        		alert("操作出错！请重试...");
			        		location.href="/helloworld/user_add.html";
			        	}
			        }
			    });
    		}
		});
		</script>
	</body>
</html>